package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClue;

import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueService;
import com.huike.clues.service.ITbClueTrackRecordService;

import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;

    @Autowired
    private ITbClueService iTbClueService;

    /**
     * 线索跟进添加
     * @param clueTrackRecordVo
     * @return
     */
    @Override
    public int add(ClueTrackRecordVo clueTrackRecordVo) {
            //获取用户名
            String username = SecurityUtils.getUsername();
            //获取线索管理对象
            TbClue tbClue = new TbClue();
            //将线索的全部信息拷贝进线索管理对象
            BeanUtils.copyProperties(clueTrackRecordVo,tbClue);
            //设置线索id
            tbClue.setId(clueTrackRecordVo.getClueId());
            iTbClueService.updateTbClue(tbClue);
            clueTrackRecordVo.setCreateBy(username);
            Integer num = tbClueTrackRecordMapper.saveClueTrackRecord(clueTrackRecordVo);
            return num;
    }

    /**
     * 线索跟进查询
     * @param
     * @return
     */
    @Override
    public List<TbClueTrackRecord> selectAllClueTrackRecord(Long clueId) {
        List<TbClueTrackRecord> tbClueTrackRecords = tbClueTrackRecordMapper.selectAllClueTrackRecord(clueId);
        return tbClueTrackRecords;
    }

}